package com.siqi.hr.system.organization.entity;

import com.siqi.hr.system.custom.entity.EntityRecord;
import com.siqi.hr.system.custom.entity.EntityType;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 权限菜单对象实体
 * @author    xiaogq
 * Created by xiaogoingqin on 2016/7/23.
 */
public class Menu {

    public Menu() {
    }

    public Menu(int id) {
        this.id = id;
    }

    /**
     * 菜单id
     */
    private Integer id;

    /**
     * 菜单名
     */
    private String name;

    /**
     * 菜单等级(1:一级菜单，2:二级菜单，3:三级菜单目前只考虑到三级)
     */
    private Integer level;

    /**
     * 是否是父级菜单
     */
    private Boolean isparent;

    /**
     * 父级菜单id
     */
    private Integer pid;

    /**
     * 排序
     */
    private Integer position;

    /**
     * 请求跳转路径
     */
    private String url;

    /**
     * 实体id
     */
    private EntityRecord entity;

    /**
     * 实体类型id
     */
    private EntityType entityType;

    /**
     * 菜单是否失效
     */
    private Boolean flag;

    /**
     * 菜单图标
     */
    private String icon;

    /**
     * 所属模块
     */
    private String belongMudule;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public Boolean getIsparent() {
        return isparent;
    }

    public void setIsparent(Boolean isparent) {
        this.isparent = isparent;
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public Integer getPosition() {
        return position;
    }

    public void setPosition(Integer position) {
        this.position = position;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public EntityRecord getEntity() {
        return entity;
    }

    public void setEntity(EntityRecord entity) {
        this.entity = entity;
    }

    public EntityType getEntityType() {
        return entityType;
    }

    public void setEntityType(EntityType entityType) {
        this.entityType = entityType;
    }

    public Boolean getFlag() {
        return flag;
    }

    public void setFlag(Boolean flag) {
        this.flag = flag;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getBelongMudule() {
        return belongMudule;
    }

    public void setBelongMudule(String belongMudule) {
        this.belongMudule = belongMudule;
    }

    //查询权限菜单有用字段信息(xiaogq)
    public static class getAllMenu extends Dept implements RowMapper<Menu> {
        public synchronized Menu mapRow(ResultSet rs, int index) throws SQLException {
            Menu menu = new Menu();
            menu.setId(rs.getInt("id"));
            menu.setName(rs.getString("name"));
            menu.setLevel(rs.getInt("level"));
            menu.setIsparent(rs.getBoolean("is_parent"));
            menu.setPid(rs.getInt("pid"));
            menu.setPosition(rs.getInt("position"));
            menu.setUrl(rs.getString("url"));
            menu.setFlag(rs.getBoolean("flag"));
            menu.setIcon(rs.getString("icon"));
            menu.setEntity(new EntityRecord(rs.getInt("entity_id")));
            menu.setBelongMudule(rs.getString("belong_mudule"));
            return menu;
        }
    }
}
